home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Fritz: All Fritz
/
All Fritz.zip
/
All Fritz
/
FILES
/
PROGMISC
/
FORTRAN1.LZH
/
KEYHIT.FOR
< prev
next >
Wrap
Text File
|
1988-02-08
|
4KB
|
134 lines
SUBROUTINE KEYHIT ( CHAR, ERROR )
C*
C* *******************************
C* *******************************
C* ** **
C* ** KEYHIT **
C* ** **
C* *******************************
C* *******************************
C*
C* SUBPROGRAM :
C* KEY HIT
C*
C* AUTHOR :
C* ART RAGOSTA
C* MS207-5
C* AMES RESEARCH CENTER
C* MOFFETT FIELD, CALIF 94035
C* (415) 694-5578
C* NOTE: THIS ROUTINE IS BASED ON THE DECUS ROUTINE 'READKEY' BY R.F.WREN
C*
C*
C* PURPOSE :
C* THIS ROUTINE CHECKS THE KEYBOARD TO SEE IF A KEY HAS BEEN
C* STRUCK. IF SO, THE ASCII VALUE OF THE CHARACTER IS RETURNED
C* IN CHAR; OTHERWISE, 0 IS RETURNED IN CHAR.
C*
C* INPUT ARGUMENTS :
C* NONE
C*
C* OUTPUT ARGUMENTS :
C* CHAR - THE ASCII INTEGER CHARACTER THAT WAS ENTERED, OR 0
C* ERROR - TRUE IF AN ERROR OCCURRED.
C*
C* INTERNAL WORK AREAS :
C* NONE
C*
C* COMMON BLOCKS :
C* NONE
C*
C* FILE REFERENCES :
C* NONE
C*
C* SUBPROGRAM REFERENCES :
C* SYS$ASSIGN, SUS$GET_EF, SYS$CLREF, SYS$QIOW
C*
C* ERROR PROCESSING :
C* PASSES ALONG THE ERROR CODES FROM THE SYSTEM SERVICES
C*
C* TRANSPORTABILITY LIMITATIONS :
C* NOT TRANSPORTABLE
C*
C* ASSUMPTIONS AND RESTRICTIONS :
C* THIS ROUTINE WORKS ONLY TO 'TT:'
C* THE USER SHOULD ALWAYS CHECK THE VALUE OF 'ERROR' IN THE
C* CALLING PROGRAM.
C*
C* LANGUAGE AND COMPILER :
C* ANSI FORTRAN 77
C*
C* VERSION AND DATE :
C* VERSION I.0 28-FEB-85
C*
C* CHANGE HISTORY :
C* 28-FEB-85 INITIAL VERSION
C*
C***********************************************************************
C*
IMPLICIT INTEGER (A-Z)
EXTERNAL SS$_NORMAL, IO$_TTYREADALL, IO$M_TIMED, IO$M_NOECHO
EXTERNAL SS$_WASCLR, SS$_WASSET
SAVE INIT, TERM_CHAN, KEYBOARD_EF, READ_FUNC
LOGICAL ERROR, INIT
BYTE CHAR
DATA NO_TIME /0/, INIT/.FALSE./
C
C... ERROR MASKS
C
INTEGER*2 IOSB(4)
DATA STATUS /1/, BYTECNT /2/, TERMINATOR /3/, TERMINSIZ /4/
C
C... TERMINATOR TABLE WITH NO TERMINATORS
C
INTEGER*4 NO_TERMINATORS(2), TERM_MASK(8)
DATA NO_TERMINATORS /32,0/
DATA TERM_MASK /'00000000'X,'00000000'X,'00000000'X,'00000000'X,
$ '00000000'X,'00000000'X,'00000000'X,'00000000'X/
NO_TERMINATORS(2) = %LOC(TERM_MASK)
C
ERROR = .FALSE.
IF (.NOT. INIT) THEN
C
C ASSIGN AN IO CHANNEL FOR TT:
C
ISTAT = SYS$ASSIGN ('TT', TERM_CHAN,,)
IF (ISTAT .NE. %LOC(SS$_NORMAL)) THEN
ERROR = .TRUE.
RETURN
ENDIF
C
C ALLOCATE AN EVENT FLAG AND CLEAR IT
C
ISTAT = LIB$GET_EF(KEYBOARD_EF)
IF (ISTAT .NE. %LOC(SS$_NORMAL)) THEN
ERROR = .TRUE.
RETURN
ENDIF
ISTAT = SYS$CLREF (%VAL(KEYBOARD_EF))
IF (ISTAT .NE. %LOC(SS$_WASCLR) .AND.
$ ISTAT .NE. %LOC(SS$_WASSET)) THEN
ERROR = .TRUE.
RETURN
ENDIF
READ_FUNC = %LOC(IO$_TTYREADALL) .OR. %LOC(IO$M_TIMED) .OR.
$ %LOC(IO$M_NOECHO)
INIT = .TRUE.
ENDIF
C
C INITIATE A SINGLE CHARACTER READ
C
ISTAT = SYS$QIOW (%VAL(KEYBOARD_EF), %VAL(TERM_CHAN),
$ %VAL(READ_FUNC), IOSB,,, CHAR, %VAL(1),
$ %VAL(NO_TIME), NO_TERMINATORS,,)
C
C IGNORE ANY ERRORS
C
IF (IOSB(STATUS) .NE. %LOC(SS$_NORMAL) .OR.
$ IOSB(BYTECNT) .NE. 1) CHAR = 0
RETURN
END
C
C---END KEYHIT
C